//
//  KTHttpUtils.h
//  BoWuGuan
//
//  Created by 梁尚嘉 on 2016/10/31.
//  Copyright © 2016年 KT. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "KTURLSessionTask.h"


extern NSString *const OM_NOTIFICATION_KEY_LOGIN_SUCCESS;
extern NSString *const OM_NOTIFICATION_KEY_LOGOUT_SUCCESS;
typedef NS_ENUM(NSUInteger, KTServerMode) {
    KTServerDebugMode,      //开发环境
    KTServerProductMode,    //正式环境
};

typedef void (^KTHttpUtilCompletion) (id responseObject, BOOL isSuccess, NSString *message);
typedef void (^KTHttpUtilProgress) (NSProgress *progress);
typedef void (^KTHttpUtilReverse) (BOOL isReverse);
typedef void (^KTHttpUtilLoginResult) (BOOL isSuccess,NSString *message);
typedef void (^KTSubmitionBlock) (BOOL isSuccess);


@interface KTHttpUtils : NSObject

//**开始工作(必须）
+ (void)startRunning;

//设置请求的环境
+ (void)setServerMode:(KTServerMode)mode;


+ (BOOL)isDebug;

//当前请求的环境
+ (NSString *)currentMode;


+ (BOOL)is_WIFI_reachable;

+ (BOOL)is_WWAN_reachable;


/**有缓存的GET请求1*/
+ (KTURLSessionTask *)GET:(NSString *)URLString
               completion:(KTHttpUtilCompletion)completion;

/**有缓存的GET请求2*/
+ (KTURLSessionTask *)GET:(NSString *)URLString
               parameters:(id)parameters
                 progress:(KTHttpUtilProgress)downloadProgress
               completion:(KTHttpUtilCompletion)completion;

/**无缓存的GET请求*/
+ (KTURLSessionTask *)GET_NOCACHE:URLString
                       parameters:(id)parameters
                         progress:(KTHttpUtilProgress)progress
                       completion:(KTHttpUtilCompletion)completion;

+ (KTURLSessionTask *)GET:(NSString *)URLString
               parameters:(id)parameters
                needCache:(BOOL)needCache
                needToken:(BOOL)needToken
                 progress:(KTHttpUtilProgress)progress
               completion:(KTHttpUtilCompletion)completion;



+ (KTURLSessionTask *)POST:(NSString *)URLString
                parameters:(id)parameters
                  progress:(KTHttpUtilProgress)uploadProgress
                completion:(KTHttpUtilCompletion)completion;
/**无token的post请求*/
+ (KTURLSessionTask *)POST:(NSString *)URLString
                parameters:(NSDictionary *)parameters
                 needToken:(BOOL)needToken
                  progress:(KTHttpUtilProgress)progress
                completion:(KTHttpUtilCompletion)completion;


+ (KTURLSessionTask *)DELETE:(NSString *)URLString
                  parameters:(id)parameters
                  completion:(KTHttpUtilCompletion)completion;


+ (void)loginWithUserName:(NSString *)username
                 password:(NSString *)password
                 onResult:(KTHttpUtilLoginResult)result;

+ (void)autoLoginOnResult:(KTHttpUtilLoginResult)result;

//图片上传
+ (KTURLSessionTask *)UPLOADImage:(NSString *)pix
                       parameters:(id)parameters
                         fileURLs:(NSArray<NSURL *> *)fileURLs
                         progress:(KTHttpUtilProgress)uploadProgress
                       completion:(KTHttpUtilCompletion)completion;


+ (KTURLSessionTask *)checkAppVersion;


+ (NSString *)currentDomainPrefix;

+ (void)setDebugDomain:(NSString *)domain;

+ (NSString *)imageURLWithPix:(NSString *)pix;

+ (void)clearCookies;



@end
